CC_CROSS:=aarch64-mix210-linux-

PWD    ?= $(shell pwd)
OUTDIR ?= $(PWD)/out
CROSS  ?= $(CC_CROSS)

CC = $(CROSS)g++
AR = $(CROSS)ar -ar
LD = $(CROSS)ld

SUBDIRS = TestBench TestMain

SRC_FILES := $(wildcard *.cpp)
OBJ_FILES := $(SRC_FILES:.cpp=.o)

SUB_FILES := 
EXT_FILES := 

subdir     := $(addprefix build_,$(SUBDIRS) )
clean_dirs := $(addprefix clean_,$(SUBDIRS) )

export PWD
export CROSS
export OUTDIR

# default rule
default: all

$(OUTDIR):
	@if [ ! -d $(OUTDIR) ]; then \
		mkdir $(OUTDIR); \
	fi

$(SUBDIRS):
	@echo "CROSS = $(CROSS) . $(CC_CROSS)"
	make -C $@

$(subdir):
	@echo "CC  $@"
	@echo "CROSS = $(CROSS) . $(CC_CROSS)"
	$(MAKE) -C $(patsubst build_%,%,$@)

$(clean_dirs):
	$(MAKE) -C $(patsubst clean_%,%,$@) clean

# phony rules
.PHONY: all 
all: $(OUTDIR) $(subdir)

.PHONY: clean
clean: $(clean_dirs)
	rm -f *.o
	@echo "--- clean done ---"

help:
	@echo "make CROSS=aarch64-mix210-linux-"
	@echo "           arm-mix410-linux-"